
package app;

import java.io.Serializable;
import java.net.InetAddress;

import javax.swing.ImageIcon;

import util.Constants;

public class User implements Serializable, Comparable<User> {
	
	public User(){
		id = -1;
		image = Constants.DEFAULT_IMAGE;
	}
	
	public User(String nick) {
		this();
		this.nick = nick;
	}
	
	public User(long id) {
		this();
		this.id = id;
	}
	
	public User(String nick, long id) {
		this(nick);
		this.id = id;
	}
	
	public long getId() {
		return id;
	}
	
	public String getNick() {
		return nick;
	}
	
	public InetAddress getIp() {
		return ip;
	}
	
	public ImageIcon getImage() {
		return image;
	}
	
	public void setId(long d) {
		this.id = d;
	}
	
	public void setNick(String nick) {
		this.nick = nick;
	}
	
	public void setIp(InetAddress ip) {
		this.ip = ip;
	}

	public String getPathImage() {
		return pathImage;
	}

	public void setPathImage(String pathImage) {
		this.pathImage = pathImage;
		image = new ImageIcon(pathImage);
	}

	public boolean equals(Object o) {
		User u = (User)o;
		return ((u.id == id) && (u.nick.equals(nick)));
	}
	
	public int compareTo(User u) {
		return equals(u) ? 0 : -1 ;
	}
	
	public String toString() {
		return nick+"/"+id;
	}
	
	private static final long serialVersionUID = -1022398445181409865L;
	
	private long id;
	private String nick;
	private InetAddress ip;
	private ImageIcon image;
	private String pathImage;
}
